package com.hup.restTimer.view.setting;

import com.hup.utils.swing.FrameUtil.Gravity;
import com.hup.utils.swing.customView.BaseUndoText;
import com.hup.utils.swing.customView.ColorBackgroundLabel;
import com.hup.utils.swing.customView.FileChooserPanel;
import com.hup.utils.swing.customView.FileChooserPanel.FileSelectionMode;
import com.hup.utils.swing.customView.HComboBox;
import com.hup.utils.swing.customView.HintTextField;
import com.hup.utils.swing.customView.spinner.IntSpinner;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.border.TitledBorder;
import javax.swing.undo.UndoManager;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

/**
 * @author hugan
 * @date 2022/10/1
 */
public class SettingForm {
    public JPanel root;

    /**
     * 单位分钟
     */
    public IntSpinner txtSitTimeMax;
    public JButton btnResetSitTime;
    public JLabel txtNotSupportPenetration;
    //
    public HintTextField txtTipsTemplate;
    public HintTextField txtTipsTemplateRest;
    public HComboBox<String> cbFont;
    public IntSpinner txtFontSize;
    public ColorBackgroundLabel txtColor;
    public HComboBox<Gravity> cbGravity;
    public IntSpinner txtMargin;
    public JCheckBox cbTipsOutline;
    //休息背景图
    public JCheckBox cbImageShow;
    public JCheckBox cbImagePenetration;
    /**
     * 实际是"不透明度"
     */
    public JSlider slImageAlpha;
    public FileChooserPanel txtImagePath;
    public IntSpinner txtImageChangeTime;
    public JCheckBox cbImageRandom;

    public SettingForm() {
        $$$setupUI$$$();

        BaseUndoText.initUndo(txtTipsTemplate, new UndoManager());
        BaseUndoText.initUndo(txtTipsTemplateRest, new UndoManager());
        cbGravity.setModel(Gravity.values());
        cbGravity.setItemTextHandler(value -> value.text);
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        root = new JPanel();
        root.setLayout(new GridBagLayout());
        root.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new GridBagLayout());
        GridBagConstraints gbc;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(panel1, gbc);
        panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), "提醒文本", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        txtTipsTemplate = new HintTextField();
        txtTipsTemplate.setToolTipText("使用'#'代表时间占位符,如'已久坐 #'");
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.gridwidth = 3;
        gbc.weightx = 1.0;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel1.add(txtTipsTemplate, gbc);
        cbFont = new HComboBox();
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 2;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel1.add(cbFont, gbc);
        cbGravity = new HComboBox();
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 3;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel1.add(cbGravity, gbc);
        txtFontSize = new IntSpinner();
        txtFontSize.setIntValue(28);
        txtFontSize.setMax(500);
        txtFontSize.setMin(28);
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = 2;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel1.add(txtFontSize, gbc);
        txtMargin = new IntSpinner();
        txtMargin.setIntValue(28);
        txtMargin.setMax(500);
        txtMargin.setMin(0);
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 4;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel1.add(txtMargin, gbc);
        final JLabel label1 = new JLabel();
        label1.setText("久坐文本");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(0, 5, 0, 5);
        panel1.add(label1, gbc);
        final JLabel label2 = new JLabel();
        label2.setText("休息文本");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(0, 5, 0, 5);
        panel1.add(label2, gbc);
        txtTipsTemplateRest = new HintTextField();
        txtTipsTemplateRest.setToolTipText("使用'#'代表时间占位符,如'已休息 #'");
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 1;
        gbc.gridwidth = 3;
        gbc.weightx = 1.0;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel1.add(txtTipsTemplateRest, gbc);
        final JLabel label3 = new JLabel();
        label3.setText("字体");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(0, 5, 0, 5);
        panel1.add(label3, gbc);
        final JLabel label4 = new JLabel();
        label4.setText("位置");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 3;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(0, 5, 0, 5);
        panel1.add(label4, gbc);
        final JLabel label5 = new JLabel();
        label5.setText("边距");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 4;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(0, 5, 0, 5);
        panel1.add(label5, gbc);
        cbTipsOutline = new JCheckBox();
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 5;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(0, 5, 0, 0);
        panel1.add(cbTipsOutline, gbc);
        txtColor = new ColorBackgroundLabel();
        txtColor.setBackground(new Color(-10158297));
        txtColor.setText("  (100,255,255)  ");
        gbc = new GridBagConstraints();
        gbc.gridx = 3;
        gbc.gridy = 2;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.VERTICAL;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel1.add(txtColor, gbc);
        final JLabel label6 = new JLabel();
        label6.setText("文字描边");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 5;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel1.add(label6, gbc);
        final JPanel spacer1 = new JPanel();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 5;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.VERTICAL;
        root.add(spacer1, gbc);
        final JPanel panel2 = new JPanel();
        panel2.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(panel2, gbc);
        panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), "一般设置", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        final JLabel label7 = new JLabel();
        label7.setText("久坐时长(分钟)");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(0, 5, 0, 5);
        panel2.add(label7, gbc);
        txtSitTimeMax = new IntSpinner();
        txtSitTimeMax.setMax(600);
        txtSitTimeMax.setMin(1);
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        panel2.add(txtSitTimeMax, gbc);
        final JPanel spacer2 = new JPanel();
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        panel2.add(spacer2, gbc);
        btnResetSitTime = new JButton();
        btnResetSitTime.setText("重置时久坐长");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.gridwidth = 2;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel2.add(btnResetSitTime, gbc);
        txtNotSupportPenetration = new JLabel();
        txtNotSupportPenetration.setForeground(new Color(-65536));
        txtNotSupportPenetration.setText("当前系统不支持鼠标穿透");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.gridwidth = 3;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(0, 5, 5, 0);
        panel2.add(txtNotSupportPenetration, gbc);
        final JPanel panel3 = new JPanel();
        panel3.setLayout(new GridBagLayout());
        panel3.setMinimumSize(new Dimension(0, 8));
        panel3.setPreferredSize(new Dimension(0, 8));
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(panel3, gbc);
        final JPanel panel4 = new JPanel();
        panel4.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 4;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(panel4, gbc);
        panel4.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), "休息背景图", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        slImageAlpha = new JSlider();
        slImageAlpha.setMajorTickSpacing(10);
        slImageAlpha.setMaximum(255);
        slImageAlpha.setMinimum(5);
        slImageAlpha.setPaintTicks(true);
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 2;
        gbc.gridwidth = 2;
        gbc.weightx = 1.0;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(0, 0, 0, 5);
        panel4.add(slImageAlpha, gbc);
        final JLabel label8 = new JLabel();
        label8.setText("透明度");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel4.add(label8, gbc);
        final JLabel label9 = new JLabel();
        label9.setText("目录");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 3;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel4.add(label9, gbc);
        final JLabel label10 = new JLabel();
        label10.setText("换图间隔(秒)");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 4;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel4.add(label10, gbc);
        cbImageShow = new JCheckBox();
        cbImageShow.setToolTipText("休息时,显示背景图");
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(0, 5, 0, 0);
        panel4.add(cbImageShow, gbc);
        cbImagePenetration = new JCheckBox();
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 1;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(0, 5, 0, 0);
        panel4.add(cbImagePenetration, gbc);
        final JLabel label11 = new JLabel();
        label11.setText("显示背景图");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel4.add(label11, gbc);
        final JLabel label12 = new JLabel();
        label12.setText("鼠标穿透");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel4.add(label12, gbc);
        final JLabel label13 = new JLabel();
        label13.setText("随机播放");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 5;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.insets = new Insets(5, 5, 5, 5);
        panel4.add(label13, gbc);
        cbImageRandom = new JCheckBox();
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 5;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(0, 5, 0, 0);
        panel4.add(cbImageRandom, gbc);
        txtImageChangeTime = new IntSpinner();
        txtImageChangeTime.setIntValue(30);
        txtImageChangeTime.setMax(600);
        txtImageChangeTime.setMin(1);
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 4;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(0, 5, 0, 5);
        panel4.add(txtImageChangeTime, gbc);
        final JPanel spacer3 = new JPanel();
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        panel4.add(spacer3, gbc);
        txtImagePath = new FileChooserPanel();
        txtImagePath.setChooserBtnTxt("确定");
        txtImagePath.setFileSelectionMode(FileSelectionMode.DIRECTORIES_ONLY);
        txtImagePath.setHint("双击选择目录");
        txtImagePath.setLabel("");
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 3;
        gbc.gridwidth = 2;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(0, 5, 0, 5);
        panel4.add(txtImagePath, gbc);
        final JPanel panel5 = new JPanel();
        panel5.setLayout(new GridBagLayout());
        panel5.setMinimumSize(new Dimension(0, 8));
        panel5.setPreferredSize(new Dimension(0, 8));
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 3;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(panel5, gbc);
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() {
        return root;
    }

}
